package com.camp.socialtong.controller.ajax;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

import com.camp.socialtong.model.CalendarScheduleModel;
import com.camp.socialtong.service.DAOSupplyService;

public class LoadScheduleList extends AbstractCommandController {
	
	public void setDaoSupplyService(DAOSupplyService daoSupplyService) {
		this.daoSupplyService = daoSupplyService;
	}

	DAOSupplyService daoSupplyService;

	@Override
	protected ModelAndView handle(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		// TODO Auto-generated method stub
		CalendarScheduleModel calendarScheduleModel = (CalendarScheduleModel)command;
		//1. Service & Return jSon Result(JSONArray사용)
		Map<String, Object> resultJson = new HashMap<String, Object>();
		resultJson.put("data", JSONArray.fromObject((ArrayList)daoSupplyService.getCalendarScheduleDAO().selectSchedulesBySomeConditions(calendarScheduleModel)));
		return new ModelAndView("jsonView", resultJson);
	}

}
